File: /var/www/kevin-demo/wp-content/plugins/wpforms-sendinblue/src/Provider/Actions/DeleteAction.php
<?php
namespace WPFormsSendinblue\Provider\Actions;
use WPFormsSendinblue\Api\Exceptions\ResponseException;
use WPFormsSendinblue\Api\Exceptions\RequiredArgumentMissingException;
/**
* Class DeleteAction.
*
* @since 1.0.0
*/
class DeleteAction extends Action {
/**
* Run action.
*
* @since 1.0.0
*
* @throws ResponseException Invalid response.
* @throws RequiredArgumentMissingException Required argument is missing.
*/
public function run() {
$email = sanitize_email( $this->field_mapper->get_field_value_by_id( $this->field_mapper->get_required_field_value( 'email', 'field_id' ) ) );
if ( ! $email ) {
throw new RequiredArgumentMissingException( 'email' );
}
$response = $this->connection->delete_contact( $email );
if ( $response->has_errors() ) {
throw new ResponseException( esc_html( $response->get_response_message() ) );
}
}
}